<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //1 根据字符串查找下标位置 indexOf  lastindexOf
      var str = '相思是病,你是我命';
      console.log(str.indexOf('病')); // 下标3
      console.log(str.lastIndexOf('你')); //下标5

      //2.根据位置找到对应的字符
      //2.1 字符[索引]  返回对应索引的字符'
      
      console.log(str[3]); //病
      //2.2 charAt  返回对应的索引字符
      console.log(str[3]);  //病
      //2.3 charCoadeAt  返回对应索引的acall码
      console.log(str.charCodeAt(3)); //  30149  acall码
    </script>
  </body>
</html>
